package com.seamtop.cuber.common.entriy;

import com.seamtop.cuber.common.util.DateUtil;

import java.net.URLEncoder;
import java.util.Date;
import java.util.HashMap;

/**
 * Created by zongjunfeng on 2015/8/10.
 */
public class CuberMessage<T> {

    private String msgType;

    private HashMap<String,T> msgData;

    private int msgSource = 1;

    private long msgId;

    private long t;

    public CuberMessage(){
        long t = Math.round(Math.random() * 100);
        while (t<10 || t >= 100){
            t = Math.round(Math.random() * 100);
        }
        Date d = new Date();
        this.setMsgId(Long.valueOf(d.getTime() + "" + t));
        this.setT(DateUtil.getAheadRecentyDayTimeStamp(new Date(),0));
        //this.setT(d.getTime());
    }

    public String getMsgType() {
        return msgType;
    }

    public void setMsgType(String msgType) {
        this.msgType = msgType;
    }

    public HashMap<String, T> getMsgData() {
        return msgData;
    }

    public void setMsgData(HashMap<String, T> msgData) {
        for(String key:msgData.keySet()){
            T temp = msgData.get(key);
            if(temp != null){
                msgData.put(key,temp);
            }
        }
        this.msgData = msgData;
    }

    public int getMsgSource() {
        return msgSource;
    }

    public void setMsgSource(int msgSource) {
        this.msgSource = msgSource;
    }

    public long getMsgId() {
        return msgId;
    }

    public void setMsgId(long msgId) {
        this.msgId = msgId;
    }

    public long getT() {
        return t;
    }

    public void setT(long t) {
        this.t = t;
    }
}
